Skip to content

fix(core): keep a schema-only tool's declared outputSchema - #4571

Open
PHLIH wants to merge 1 commit into
agentscope-ai:mainfrom
PHLIH:fix/schema-only-output-schema
Open

PHLIH wants to merge 1 commit into
agentscope-ai:mainfrom
PHLIH:fix/schema-only-output-schema

Conversation

@PHLIH

@PHLIH PHLIH commented Dec 2, 2026

Copy link
Copy Markdown

AgentScope-Java Version

2.1.0-SNAPSHOT (main at 634fe8d)

Description

Fixes #4570.

SchemaOnlyTool(ToolSchema) copied name, description, parameters, strict and deferLoading but not outputSchema, and the class had no override for getOutputSchema(). ToolSchemaProvider builds the exposed schema with tool.getOutputSchema(), so every external tool registered through Toolkit.registerSchema(...) lost the output contract its ToolSchema declared — while strict and deferLoading from the same builder were preserved.

Changes

  • SchemaOnlyTool: new outputSchema field, defensively copied and unmodifiable like parameters; a new 6-argument constructor carries it; the ToolSchema constructor passes schema.getOutputSchema(); getOutputSchema() is overridden. The existing 3/4/5-argument constructors delegate with null, so callers that never declare an output schema see no change.
  • SchemaOnlyToolTest: two cases — the ToolSchema constructor preserves outputSchema, and a schema registered through Toolkit.registerSchema(...) still exposes it from Toolkit.getToolSchemas().

No public API break; the new constructor is additive.

Tests

mvn -pl agentscope-core spotless:check                                        -> BUILD SUCCESS
mvn -pl agentscope-core test -Dtest='SchemaOnlyToolTest,ExternalToolSupportTest,ToolSchemaProviderTest,ToolkitTest'
  -> Tests run: 94, Failures: 0, Errors: 0, Skipped: 0

Both new tests fail on the unmodified tree with

expected: <{properties={answer={type=string}}, type=object}> but was: <null>

and pass with the change.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test for the affected module and test classes)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.) — no documentation describes this constructor's field handling, so none needed
  • Code is ready for review

@CLAassistant

CLAassistant commented Dec 2, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SchemaOnlyTool silently drops the ToolSchema outputSchema, so external tools lose their declared output contract

2 participants